package com.weizicheng.service.Impl;

import com.weizicheng.dao.UserDao;
import com.weizicheng.service.UserService;

public class UserServiceImpl implements UserService {
    private String name;
    private int age;
    private UserDao dao;

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setDao(UserDao dao) {
        this.dao = dao;
    }

    public void save(){
        dao.getUser();
        System.out.println(name+" "+age);
    }

    /*构造器注入所需要创建的构造器*/
    public UserServiceImpl(UserDao userDao,String name,int age){
        this.dao=userDao;
        this.name=name;
        this.age=age;
    }

    /*set注入需要的构造方法; 默认存在, 但如果创建了有参构造, 就需要自己手动创建无参构造*/
    public UserServiceImpl(){}
    @Override
    public void getBean() {
        dao.getUser();
        System.out.println(name+" "+age);
    }
}
